﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="QuizResultsDataSet" targetNamespace="http://tempuri.org/QuizResultsDataSet.xsd" xmlns:mstns="http://tempuri.org/QuizResultsDataSet.xsd" xmlns="http://tempuri.org/QuizResultsDataSet.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop" attributeFormDefault="qualified" elementFormDefault="qualified">
  <xs:annotation>
    <xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
      <DataSource DefaultConnectionIndex="1" FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout, AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
        <Connections>
          <Connection AppSettingsObjectName="Settings" AppSettingsPropertyName="GiveAQuizConnectionString" IsAppSettingsProperty="true" Modifier="Assembly" Name="GiveAQuizConnectionString (Settings)" ParameterPrefix="@" PropertyReference="ApplicationSettings.GiveAQuiz.Reporting.Properties.Settings.GlobalReference.Default.GiveAQuizConnectionString" Provider="System.Data.SqlClient" />
          <Connection AppSettingsObjectName="Web.config" AppSettingsPropertyName="ApplicationServices" ConnectionStringObject="" IsAppSettingsProperty="true" Modifier="Assembly" Name="ApplicationServices (Web.config)" ParameterPrefix="@" PropertyReference="AppConfig.System.Configuration.ConfigurationManager.0.ConnectionStrings.ApplicationServices.ConnectionString" Provider="System.Data.SqlClient" />
        </Connections>
        <Tables>
          <TableAdapter BaseClass="System.ComponentModel.Component" DataAccessorModifier="AutoLayout, AnsiClass, Class, Public" DataAccessorName="QuizTakersTableAdapter" GeneratorDataComponentClassName="QuizTakersTableAdapter" Name="QuizTakers" UserDataComponentName="QuizTakersTableAdapter">
            <MainSource>
              <DbSource ConnectionRef="ApplicationServices (Web.config)" DbObjectType="Unknown" FillMethodModifier="Public" FillMethodName="Fill" GenerateMethods="Both" GenerateShortCommands="false" GeneratorGetMethodName="GetData" GeneratorSourceName="Fill" GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="false" UserGetMethodName="GetData" UserSourceName="Fill">
                <SelectCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="true">
                    <CommandText>SELECT        qt.Name, SUM(CASE WHEN qa.Result = 'Correct' THEN 1 ELSE 0 END) AS Correct, SUM(CASE WHEN qa.Result = 'Undetermined' THEN 1 ELSE 0 END) AS Undetermined, COUNT(quesd.Id) AS Questions, CASE WHEN (COUNT(quesd.Id) 
                         &gt; SUM(CASE WHEN qa.Result = 'Undetermined' THEN 1 ELSE 0 END)) THEN ROUND(CAST(SUM(CASE WHEN qa.Result = 'Correct' THEN 1 ELSE 0 END) 
                         AS decimal(4, 2)) / (COUNT(quesd.Id) - SUM(CASE WHEN qa.Result = 'Undetermined' THEN 1 ELSE 0 END)), 2) ELSE 0 END AS Percentage, 
                         qr.Id AS QuizResultId
FROM            GiveAQuiz.QuestionDefinitions AS quesd INNER JOIN
                         GiveAQuiz.QuizDefinitions AS quizd ON quizd.Id = quesd.QuizDefinition INNER JOIN
                         GiveAQuiz.Quizzes AS q ON quesd.QuizDefinition = q.QuizDefinitionID INNER JOIN
                         GiveAQuiz.QuizResults AS qr ON qr.Quiz = q.Id INNER JOIN
                         GiveAQuiz.QuizTakers AS qt ON qr.QuizTaker = qt.Id INNER JOIN
                         GiveAQuiz.QuizAnswers AS qa ON quesd.Id = qa.QuestionDefinition AND qr.Id = qa.QuizResult
WHERE        (q.Id = @QuizId)
GROUP BY qt.Name, qr.Id</CommandText>
                    <Parameters>
                      <Parameter AllowDbNull="false" AutogeneratedName="QuizId" ColumnName="Id" DataSourceName="QuizDB.GiveAQuiz.Quizzes" DataTypeServer="int" DbType="Int32" Direction="Input" ParameterName="@QuizId" Precision="0" ProviderType="Int" Scale="0" Size="4" SourceColumn="Id" SourceColumnNullMapping="false" SourceVersion="Current" />
                    </Parameters>
                  </DbCommand>
                </SelectCommand>
              </DbSource>
            </MainSource>
            <Mappings>
              <Mapping SourceColumn="Name" DataSetColumn="Name" />
              <Mapping SourceColumn="Correct" DataSetColumn="Correct" />
              <Mapping SourceColumn="Questions" DataSetColumn="Questions" />
              <Mapping SourceColumn="QuizResultId" DataSetColumn="QuizResultId" />
              <Mapping SourceColumn="Percentage" DataSetColumn="Percentage" />
              <Mapping SourceColumn="Undetermined" DataSetColumn="Undetermined" />
            </Mappings>
            <Sources />
          </TableAdapter>
          <TableAdapter BaseClass="System.ComponentModel.Component" DataAccessorModifier="AutoLayout, AnsiClass, Class, Public" DataAccessorName="QuizzesTableAdapter" GeneratorDataComponentClassName="QuizzesTableAdapter" Name="Quizzes" UserDataComponentName="QuizzesTableAdapter">
            <MainSource>
              <DbSource ConnectionRef="ApplicationServices (Web.config)" DbObjectName="QuizDB.GiveAQuiz.Quizzes" DbObjectType="Table" FillMethodModifier="Public" FillMethodName="Fill" GenerateMethods="Both" GenerateShortCommands="false" GeneratorGetMethodName="GetData" GeneratorSourceName="Fill" GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="false" UserGetMethodName="GetData" UserSourceName="Fill">
                <SelectCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="true">
                    <CommandText>SELECT        q.Name, qu.FirstName + ' ' + qu.LastName AS QuizGiver
FROM            GiveAQuiz.Quizzes AS q INNER JOIN
                         GiveAQuiz.QuizDefinitions AS qd ON qd.Id = q.QuizDefinitionID INNER JOIN
                         GiveAQuiz.QuizUsers AS qu ON qd.Owner = qu.Id
WHERE        (q.Id = @QuizId)</CommandText>
                    <Parameters>
                      <Parameter AllowDbNull="false" AutogeneratedName="QuizId" ColumnName="Id" DataSourceName="QuizDB.GiveAQuiz.Quizzes" DataTypeServer="int" DbType="Int32" Direction="Input" ParameterName="@QuizId" Precision="0" ProviderType="Int" Scale="0" Size="4" SourceColumn="Id" SourceColumnNullMapping="false" SourceVersion="Current" />
                    </Parameters>
                  </DbCommand>
                </SelectCommand>
              </DbSource>
            </MainSource>
            <Mappings>
              <Mapping SourceColumn="Name" DataSetColumn="Name" />
              <Mapping SourceColumn="QuizGiver" DataSetColumn="QuizGiver" />
            </Mappings>
            <Sources />
          </TableAdapter>
        </Tables>
        <Sources />
      </DataSource>
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="QuizResultsDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:EnableTableAdapterManager="true" msprop:Generator_DataSetName="QuizResultsDataSet" msprop:Generator_UserDSName="QuizResultsDataSet">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="QuizTakers" msprop:Generator_TableClassName="QuizTakersDataTable" msprop:Generator_TableVarName="tableQuizTakers" msprop:Generator_TablePropName="QuizTakers" msprop:Generator_RowDeletingName="QuizTakersRowDeleting" msprop:Generator_UserTableName="QuizTakers" msprop:Generator_RowChangingName="QuizTakersRowChanging" msprop:Generator_RowEvHandlerName="QuizTakersRowChangeEventHandler" msprop:Generator_RowDeletedName="QuizTakersRowDeleted" msprop:Generator_RowEvArgName="QuizTakersRowChangeEvent" msprop:Generator_RowChangedName="QuizTakersRowChanged" msprop:Generator_RowClassName="QuizTakersRow">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Name" msprop:Generator_ColumnVarNameInTable="columnName" msprop:Generator_ColumnPropNameInRow="Name" msprop:Generator_ColumnPropNameInTable="NameColumn" msprop:Generator_UserColumnName="Name">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="100" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
              <xs:element name="Correct" msdata:ReadOnly="true" msprop:Generator_ColumnVarNameInTable="columnCorrect" msprop:Generator_ColumnPropNameInRow="Correct" msprop:Generator_ColumnPropNameInTable="CorrectColumn" msprop:Generator_UserColumnName="Correct" type="xs:int" minOccurs="0" />
              <xs:element name="Questions" msdata:ReadOnly="true" msprop:Generator_ColumnVarNameInTable="columnQuestions" msprop:Generator_ColumnPropNameInRow="Questions" msprop:Generator_ColumnPropNameInTable="QuestionsColumn" msprop:Generator_UserColumnName="Questions" type="xs:int" minOccurs="0" />
              <xs:element name="QuizResultId" msdata:ReadOnly="true" msdata:AutoIncrement="true" msdata:AutoIncrementSeed="-1" msdata:AutoIncrementStep="-1" msprop:Generator_ColumnVarNameInTable="columnQuizResultId" msprop:Generator_ColumnPropNameInRow="QuizResultId" msprop:Generator_ColumnPropNameInTable="QuizResultIdColumn" msprop:Generator_UserColumnName="QuizResultId" type="xs:int" />
              <xs:element name="Percentage" msdata:ReadOnly="true" msprop:Generator_ColumnVarNameInTable="columnPercentage" msprop:Generator_ColumnPropNameInRow="Percentage" msprop:Generator_ColumnPropNameInTable="PercentageColumn" msprop:Generator_UserColumnName="Percentage" type="xs:decimal" minOccurs="0" />
              <xs:element name="Undetermined" msdata:ReadOnly="true" msprop:Generator_ColumnVarNameInTable="columnUndetermined" msprop:Generator_ColumnPropNameInRow="Undetermined" msprop:Generator_ColumnPropNameInTable="UndeterminedColumn" msprop:Generator_UserColumnName="Undetermined" type="xs:int" minOccurs="0" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="Quizzes" msprop:Generator_TableClassName="QuizzesDataTable" msprop:Generator_TableVarName="tableQuizzes" msprop:Generator_TablePropName="Quizzes" msprop:Generator_RowDeletingName="QuizzesRowDeleting" msprop:Generator_UserTableName="Quizzes" msprop:Generator_RowChangingName="QuizzesRowChanging" msprop:Generator_RowEvHandlerName="QuizzesRowChangeEventHandler" msprop:Generator_RowDeletedName="QuizzesRowDeleted" msprop:Generator_RowEvArgName="QuizzesRowChangeEvent" msprop:Generator_RowChangedName="QuizzesRowChanged" msprop:Generator_RowClassName="QuizzesRow">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Name" msprop:Generator_ColumnVarNameInTable="columnName" msprop:Generator_ColumnPropNameInRow="Name" msprop:Generator_ColumnPropNameInTable="NameColumn" msprop:Generator_UserColumnName="Name">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="100" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
              <xs:element name="QuizGiver" msdata:ReadOnly="true" msprop:Generator_ColumnVarNameInTable="columnQuizGiver" msprop:Generator_ColumnPropNameInRow="QuizGiver" msprop:Generator_ColumnPropNameInTable="QuizGiverColumn" msprop:Generator_UserColumnName="QuizGiver" minOccurs="0">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="201" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
    <xs:unique name="Constraint1" msdata:PrimaryKey="true">
      <xs:selector xpath=".//mstns:QuizTakers" />
      <xs:field xpath="mstns:QuizResultId" />
    </xs:unique>
  </xs:element>
</xs:schema>